package com.atguigu.mapreduce.solution;

public class StatBean {
    private int total;
    private int max;
    private int min;
    private int count;

    public void init() {
        total = 0;
        max = Integer.MIN_VALUE;
        min = Integer.MAX_VALUE;
        count = 0;
    }

    public void append(int record) {
        total += record;
        count++;
        if (record > max) {
            max = record;
        }
        if (record < min) {
            min = record;
        }
    }

    public double getAvg() {
        return (double) total / count;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getMax() {
        return max;
    }

    public void setMax(int max) {
        this.max = max;
    }

    public int getMin() {
        return min;
    }

    public void setMin(int min) {
        this.min = min;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    @Override
    public String toString() {
        return total + "\t" + getAvg() + "\t" + max + "\t" + min;
    }
}
